<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>混入</title>
</head>
<body>
  <div id="app">
    <my-com1></my-com1>
    <my-com2></my-com2>
  </div>
</body>
<template id="com1">
  <div>
    {{ count }} -- {{ test }} - {{ doubleCount }}
    <button @click="add">加1</button>
  </div>
</template>
<template id="com2">
  <div>
    {{ count }} -- {{ test }} -- {{ doubleCount }}
    <button @click="add">加10</button>
  </div>
</template>
<script src="../lib/vue.global.js"></script>
<script>
  const Com1 = {
    template: '#com1',
    data () {
      return {
        test: '测试',
        count: 10
      }
    },
    computed: {
      doubleCount () {
        return this.count * 2
      }
    },
    mounted () {
      this.count = 100
    },
    methods: {
      add () {
        this.count++
      }
    }
  }
  const Com2 = {
    template: '#com2',
    data () {
      return {
        test: '测试',
        count: 50
      }
    },
    computed: {
      doubleCount () {
        return this.count * 2
      }
    },
    mounted () {
      this.count = 100
    },
    methods: {
      add () {
        this.count += 10
      }
    }
  }

  Vue.createApp({
    components: {
      MyCom1: Com1,
      MyCom2: Com2
    }
  }).mount('#app')
</script>
</html>